package com.qlzb.taskmanagement.pojo;


import com.alibaba.fastjson.JSONObject;

/**
 *@author liuqiang
 */
public class JsonReturn implements java.io.Serializable {
    /**
     * 执行结果
     */
    private boolean flag;
    /**
     * 提示信息
     */
    private String message;
    /**
     * 错误信息
     */
    private String errorMessage;
    /*
    *数据
     */

    private Object data;
    /**
     * 单位  毫秒
     */
    private long time;

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public JsonReturn() {
        this.flag=true;
        this.message="成功";
    }
    @Override
    public String toString(){
        return JSONObject.toJSONString(this);
    }
    public JsonReturn(boolean flag, String message, Object data) {
        this.flag = flag;
        this.message = message;
        this.data = data;
    }
    public  JsonReturn FALSE(String message){
        this.flag = false;
        this.message = message;
        return this;
    }
    public  JsonReturn ERROR(Exception e){
        e.printStackTrace();
        this.setFlag(false);
        this.setErrorMessage(e.getMessage());
        this.setMessage("系统故障！请稍后重试");
        return this;
    }
}
